package com.boot.unity.api.common;


import java.util.HashMap;
import java.util.Map;

/**
 * 多伦响应体
 * @author lz
 * @date 2022/8/22
 */
public class DLRes extends HashMap<String, Object> {

    public DLRes() {
        put("errorcode", 0);
        put("message", "success");
    }

    public DLRes put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public static DLRes ok() {
        DLRes res = new DLRes();
        return res;
    }

    public static DLRes ok(String msg) {
        DLRes res = new DLRes();
        res.put("message", msg);
        return res;
    }

    public static DLRes ok(Map<String, Object> map) {
        DLRes res = new DLRes();
        res.putAll(map);
        return res;
    }

    public static DLRes error(int code, String msg) {
        DLRes res = new DLRes();
        res.put("errorcode", code);
        res.put("message", msg);
        return res;
    }
}
